package com.tbit.uqbike.object.pojo.dto;

import com.tbit.uqbike.constant.FaultType;
import com.tbit.uqbike.manager.exception.BaseException;
import lombok.Data;
import org.springframework.util.StringUtils;

/**
 * @Author LHX
 * @ClassName FaultReportDTO
 * @Description
 * @date 2023/5/19 10:10
 * @Version 1.0
 */
@Data
public class FaultReportDTO {
    /**
     * 区域id
     */
    private Integer accountId;

    /**
     * 起始时间
     */
    private String startTime;

    /**
     * 结束时间
     */
    private String endTime;

    /**
     * 车辆编号
     */
    private String userCode;

    /**
     * 上报人手机号(联系方式)
     */
    private String addManPhone;
    /**
     * 操作人手机号
     */
    private String operationPhone;
    private String orderNO;

    /**
     * 故障类型
     */
    private String faults;

    /**
     * 故障来源 0运维1用户
     */
    private Integer intoMain;

    private Integer page;

    private Integer size;

    /**
     * 兼容用户端故障类型
     */
    public void parseFaults() {
        if (!StringUtils.hasText(faults) || intoMain != 1) {
            return;
        }
        switch (faults) {
            case FaultType.TYPE_OTHER_USER:
                faults = FaultType.OTHER_USER;
                break;
            case FaultType.TYPE_HAVE_ELECTRICITY_USER:
                faults = FaultType.HAVE_ELECTRICITY_USER;
                break;
            case FaultType.TYPE_BRAKE_FAILURE_USER:
                faults = FaultType.BRAKE_FAILURE_USER;
                break;
            case FaultType.TYPE_SEAT_CUSHION_DAMAGED_USER:
                faults = FaultType.SEAT_CUSHION_DAMAGED_USER;
                break;
            case FaultType.TYPE_BRACE_DAMAGE_USER:
                faults = FaultType.BRACE_DAMAGE_USER;
                break;
            case FaultType.TYPE_QR_CODE_DAMAGE_USER:
                faults = FaultType.QR_CODE_DAMAGE_USER;
                break;
            case FaultType.TYPE_HELMET_DAMAGE_USER:
                faults = FaultType.HELMET_DAMAGE_USER;
                break;
            case FaultType.TYPE_SPEAKER_USER:
                faults = FaultType.SPEAKER_USER;
                break;
            default:
                break;
        }
    }

    /**
     * 查询处理记录详情,必须携带以下参数之一
     */
    public void selectDetailParamCheck() {
        //使用intoMain参输来区分是否查询处理记录
        if (this.intoMain != null) {
            return;
        }
        if (org.apache.commons.lang3.StringUtils.isAllBlank(this.userCode, this.addManPhone, this.orderNO)) {
            throw new BaseException("请填写[车辆编号、联系方式、故障编号]任意项进行查询");
        }
    }

}
